package com.spring.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Rest风格的URL：
 * 新增： /order POST
 * 修改： /order/1 PUT     --> update?id=1
 * 获取：/order/1 GET  -->get?id=1
 * 删除：/order/1  DELETE  --> delete?id=1
 *
 * 如何发送PUT请求和DELETE请求呢？
 *  1.需要web.xml配置HiddenHttpMethodFilter
 *  2.需要发送POST请求
 *  3.需要在发送POST请求时携带一个name="_method"的隐藏域，值为DELETE或PUT
 */
@RestController
public class RestfulController {

	//HiddenHttpMethodFilter
	@RequestMapping(value = "/rest/1",method = RequestMethod.GET)
	public  String get(){
		return "get";
	}
	@RequestMapping(value = "/rest/1",method = RequestMethod.PUT)
	public  String put(){
		return "put";
	}
	@RequestMapping(value = "/rest/1",method = RequestMethod.DELETE)
	public  String del(){
		return "del";
	}
	@RequestMapping(value = "/rest",method = RequestMethod.POST)
	public  String post(){
		return "post";
	}
}
